<template>
  <div id="searchPage">
    <div class="index-page-top-height">
      <div class="index-page-top-wrap" @click="query()">
        <div id="search-box" class="search-index">
          <div class="search-index-box"><i class="icon-global-search iconfont">&#xe62b;</i><span>搜索商铺或写字楼</span>
          </div>
        </div>
      </div>
    </div>
    <search-api :isActive="isActive" @showActive="showActive" @searchRes="searchRes"></search-api>
    <div class="filter-sort">
      <div class="filter-sort-height">
        <div class="filter-sort_box">
          <ul class="filter-sort_ul">
            <li :class="[ 'filter-sort_ul_li',{'isFilter' : currentFilter == 'city'}]" @click="selectFilter('city')">
              城市
              <i :class="[ 'iconfont',{'isFilter' : currentFilter == 'city'}]">{{isSortActive?'&#xe6f0;':'&#xe734;'}}</i>
            </li>
            <li :class="[ 'filter-sort_ul_li',{'isFilter' : currentFilter == 'region'}]" @click="selectFilter('region')">
              区域
              <i :class="[ 'iconfont',{'isFilter' : currentFilter == 'region'}]">{{isSortActive?'&#xe6f0;':'&#xe734;'}}</i>
            </li>
            <li :class="[ 'filter-sort_ul_li',{'isFilter' : currentFilter == 'area'}]" @click="selectFilter('area')">
              面积
              <i :class="[ 'iconfont',{'isFilter' : currentFilter == 'area'}]">{{isSortActive?'&#xe6f0;':'&#xe734;'}}</i>
            </li>
            <li :class="[ 'filter-sort_ul_li',{'isFilter' : currentFilter == 'price'}]" @click="selectFilter('price')">
              价格
              <i :class="[ 'iconfont',{'isFilter' : currentFilter == 'price'}]">{{isSortActive?'&#xe6f0;':'&#xe734;'}}</i>
            </li>
          </ul>
        </div>
      </div>        
      <div class="filterList_product_list_box">
        <div class="filterList_tour_allproduct">
          <ul class="filterList_tour_list">
            <li v-for="(item,index) in 20" :key="index">{{item}}.{{msg}}</li>
          </ul>
        </div>
      </div>
    </div>
    <div>
      <div class="filter_line_box" v-if="currentFilter=='city'">
        <div class="filter_line_height">
          <div class="filterList_line_special">
            <p class="filterList_line_title filterList_filtrate_time_title01" style="padding-bottom: 0px;">
              <span class="filterList_title_main">热门城市</span>
              <i class="filterList_filtrate_time_down iconfont">&#xe600;</i>
              <span class="filterList_line_name">展开</span>
            </p>
            <div class="filterList_flex_box">
              <div class="filterList_line_item_box" v-for="(item,index) in citys.hotCitys" :key="index">
                <div class="filterList_line_item" @click="selectItem(item.cityName)">
                  <p class="filterList_clamp2">{{item.cityName}}</p>
                </div>
              </div>
            </div>
          </div>
          <div class="filterList_line_special">
            <p class="filterList_line_title filterList_filtrate_time_title01" style="padding-bottom: 0px;">
              <span class="filterList_title_main">其他城市</span>
              <i class="filterList_filtrate_time_down iconfont">&#xe600;</i>
              <span class="filterList_line_name">展开</span>
            </p>
            <div class="filterList_flex_box">
              <div class="filterList_line_item_box" v-for="(item,index) in citys.otherCitys" :key="index">
                <div class="filterList_line_item" @click="selectItem(item.cityName)">
                  <p class="filterList_clamp2">{{item.cityName}}</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div v-if="currentFilter=='city'" class="warp_z" style="z-index: 0; display: block;"></div>
    </div>
    <div>
      <div class="filter_line_box" v-if="currentFilter=='region'">
        <div class="filter_line_height">
          <div class="filterList_line_special">
            <p class="filterList_line_title filterList_filtrate_time_title01" style="padding-bottom: 0px;">
              <span class="filterList_title_main">区域</span>
              <i class="filterList_filtrate_time_down iconfont">&#xe600;</i>
              <span class="filterList_line_name">展开</span>
            </p>
            <div class="filterList_flex_box">
              <div class="filterList_line_item_box" v-for="(item,index) in regionList" :key="index">
                <div class="filterList_line_item" @click="selectItem(item.areaName)">
                  <p class="filterList_clamp2">{{item.areaName}}</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div v-if="currentFilter=='region'" class="warp_z" style="z-index: 0; display: block;"></div>
    </div>
    <div>
      <div class="filter_line_box" v-if="currentFilter=='area'">
        <div class="filter_line_height">
          <div class="filterList_line_special">
            <p class="filterList_line_title filterList_filtrate_time_title01" style="padding-bottom: 0px;">
              <span class="filterList_title_main">区域</span>
              <!-- <i class="filterList_filtrate_time_down iconfont">&#xe600;</i>
              <span class="filterList_line_name">展开</span> -->
            </p>
            <div class="filterList_flex_box">
              <div class="filterList_line_item_box" v-for="(item,index) in areaList" :key="index">
                <div class="filterList_line_item" @click="selectItem(item.areaName)">
                  <p class="filterList_clamp2">{{item.areaName}}</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div v-if="currentFilter=='area'" class="warp_z" style="z-index: 0; display: block;"></div>
    </div>
    <div>
      <div class="filter_line_box" v-if="currentFilter=='price'">
        <div class="filter_line_height">
          <div class="filterList_line_special">
            <p class="filterList_line_title filterList_filtrate_time_title01" style="padding-bottom: 0px;">
              <span class="filterList_title_main">价格</span>
              <!-- <i class="filterList_filtrate_time_down iconfont">&#xe600;</i>
              <span class="filterList_line_name">展开</span> -->
            </p>
            <div class="filterList_flex_box">
              <div class="filterList_line_item_box" v-for="(item,index) in priceList" :key="index">
                <div class="filterList_line_item" @click="selectItem(item.priceName)">
                  <p class="filterList_clamp2">{{item.priceName}}</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div v-if="currentFilter=='price'" class="warp_z" style="z-index: 0; display: block;"></div>
    </div>

  </div>
</template>

<script>
  import search from './components/search'
  export default ({
    data() {
      return {
        isActive: false,
        msg: undefined,
        isSortActive: true,
        currentFilter: undefined,
        citys:{
          hotCitys:[
            {id:1,cityName:'上海'},
            {id:2,cityName:'北京'},
            {id:3,cityName:'深圳'},
            {id:4,cityName:'厦门'}
          ],
          otherCitys:[
            {id:1,cityName:'重庆'},
            {id:2,cityName:'南京'},
            {id:3,cityName:'苏州'},
            {id:4,cityName:'武汉'}
          ]
        },
        regionList:[
          {id:1,areaName:'静安区'},
          {id:2,areaName:'黄浦区'},
          {id:3,areaName:'普陀区'},
          {id:4,areaName:'长宁区'},
          {id:5,areaName:'杨浦区'},
          {id:6,areaName:'浦东新区'},
          {id:7,areaName:'宝山区'},
          {id:8,areaName:'松江区'},
          {id:9,areaName:'青浦区'},
        ],
        areaList:[
          {id:1,areaName:'100㎡以下'},
          {id:2,areaName:'100-200㎡'},
          {id:3,areaName:'200-300㎡'},
          {id:4,areaName:'300-500㎡'},
          {id:4,areaName:'500-800㎡'},
          {id:4,areaName:'800-1200㎡'},
          {id:9,areaName:'1200㎡以上'},
        ],
        priceList:[
          {id:1,priceName:'3元以下'},
          {id:2,priceName:'3-6元'},
          {id:3,priceName:'6-9元'},
          {id:4,priceName:'9-12元'},
          {id:9,priceName:'12元以上'},
        ]
      }
    },
    components: { 'search-api': search },
    methods: {
      query() {
        this.isActive = true;
      },
      showActive(isActive) {
        console.log(isActive)
        this.isActive = isActive
      },
      searchRes(keyword, isActive) {
        console.log(keyword)
        this.msg = keyword
        this.isActive = isActive
      },
      selectFilter(type) {
        this.currentFilter = type
        console.log(this.currentFilter)
      },
      selectItem(item){
        this.currentFilter = null
        this.msg=item
      }
    }
  })
</script>

<style scoped>
  .index-page-top-height {
    height: 44px;
  }

  .index-page-top-wrap {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1;
  }

  .search-index {
    background: #fff;
    width: 100%;
    max-width: 540px;
    height: 50px;
    z-index: 12;
    padding: 12px 12px 6px;
    box-sizing: border-box;
    transition: all .5s;
  }

  .search-index .search-index-box {
    height: 32px;
    border-radius: 16px;
    border: 1.8px solid #0086f6;
    color: #666;
    font-size: .94rem;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-pack: start;
    justify-content: flex-start;
    -ms-flex-align: center;
    align-items: center;
    box-sizing: border-box;
  }

  .search-index .search-index-box .icon-global-search {
    color: #666;
    font-size: 14px;
    margin-left: 12px;
  }

  .search-index .search-index-box span {
    margin-left: 6px;
    font-size: 15px;
    line-height: 21px;
    color: #999;
  }

  .h5_home_v1-Search:before {
    content: "\e92a";
  }

  .filter-sort-height {
    height: 36px;
  }

  .filter-sort {
    overflow: hidden;
    border-bottom: 1px solid #e4e6f0;
  }

  .filter-sort_box {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 99;
    max-width: 540px;
    margin: auto;
  }

  .filter-sort_ul {
    line-height: 36px;
    font-size: 12px;
    color: #333;
    background: #fff;
    height: 36px;
    display: flex;
    width: 100%;
    padding: 0 12px;
    box-sizing: border-box;
    border-bottom: 1px solid #f8f8f8;
  }

  .filter-sort_ul li {
    -ms-flex: 1 1;
    flex: 1 1;
    /* height: .36rem; */
    line-height: .36rem;
    text-align: center;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-align: center;
    align-items: center;
    -ms-flex-pack: center;
    justify-content: center;
  }

  .filter-sort_ul .iconfont {
    color: #e4e6f0;
  }

  .filter-sort_ul .isFilter{
    color: #0086f6;
  }

  .warp_z {
    position: fixed;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .6);
    z-index: 100;
    top: 0;
    left: 0;
  }
  .filter_line_box {
    background: #fff;
    position: fixed;
    top: 80px;
    width: 100%;
    box-sizing: border-box;
    z-index: 2;
    bottom: 100px;
    border-top: 1px solid rgba(236, 236, 236, .5);
  }

  .filter_line_height {
    height: 100%;
    overflow: auto;
    width: 100%;
    padding: 0 0 70px;
    box-sizing: border-box;
    margin-top: -1px;
  }
  .filterList_line_special:last-child {
    border-bottom: 0;
}
.filterList_line_special {
    padding: 0 8px 7px;
    border-bottom: 1px solid #ececec;
}
.filterList_filtrate_time_title01 {
    color: #333;
}
.filterList_line_title {
    font-size: 12px;
    color: #666;
    position: relative;
    padding: 10px 4px 5px;
}

.filterList_title_main {
    font-size: 14px;
    color: #333;
}
.filterList_filtrate_time_down {
    float: right;
    width: 12px;
    height: 16px;
    margin-top: -3px;
    color: #0086f6;
}
/* .filterList_filtrate_time_down:before {
    content: '\e945';
    color: #0086f6;
} */
.filterList_line_name {
    font-size: 12px;
    color: #0086f6;
    float: right;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    font-family: PingFangSC-Regular;
}
.filterList_flex_box {
    padding-top: 5px;
    display: flex;
    flex-wrap: wrap;
}
.filterList_line_item_box {
    width: 33.3%;
    float: left;
    padding: 4px;
    box-sizing: border-box;
}
.filterList_line_item {
    display: -webkit-box;
    display: -webkit-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: center;
    -webkit-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-flex-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    width: 100%;
    border-radius: 4px;
    box-sizing: border-box;
    padding: 4px 8px;
    font-size: 13px;
    float: left;
    background: #f6f8fa;
    color: #333;
    position: relative;
    box-sizing: border-box;
    flex-direction: column;
    height: 100%;
    min-height: 35px;
}
.filterList_line_item .filterList_clamp2 {
    text-align: center;
}
.filterList_clamp2 {
    -webkit-line-clamp: 2;
}
.filterList_clamp1, .filterList_clamp2, .filterList_clamp3, .filterList_clamp4, .filterList_clamp5 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
}
.filterList_flex_box:after {
    clear: both;
    content: '.';
    display: block;
    height: 0;
    overflow: hidden;
}
.filterList_product_list_box {
    padding: 0 0 44px;
}
.filterList_tour_allproduct {
    position: relative;
    background: #fff;
    overflow: hidden;
}
.filterList_tour_list li {
    overflow: hidden;
    position: relative;
    border: 0 none;
    display: -webkit-box;
    display: -webkit-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: stretch;
    -webkit-flex-align: stretch;
    -webkit-align-items: stretch;
    align-items: stretch;
    padding: 12px 0 12px 12px;
}
.filterList_tour_list li:before {
    content: '';
    position: absolute;
    left: 12px;
    bottom: 0;
    background: #eee;
    width: 100%;
    height: 1px;
    -webkit-transform: scaleY(.5);
    transform: scaleY(.5);
    -webkit-transform-origin: 0 bottom;
    transform-origin: 0 bottom;
}
</style>